﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Dapper;
using baidutieba_zhangjinyu.Models;
using baidutieba_zhangjinyu.Models.DB;
using MySql.Data.MySqlClient;

namespace baidutieba_zhangjinyu.DAL
{
    public class DAL_users
    {
        private MySqlConnection mySqlconnection = new MySqlConnection(Configpz.Configuration["MySQLConnectionString"]);
        public List<users> listusers()
        {
            var list = mySqlconnection.Query<users>("SELECT * FROM users WHERE username = @username;").ToList();
            return list;
        }
        public int insertusers(users i)
        {
            var sql = "INSERT INTO users(username,`password`,nickname,createdate) VALUES (@usernam,@password,@nickname,now());";
            var zj = mySqlconnection.Execute(sql, i);
            return zj;
        }
        public List<users> denglu()
        {
            var list = mySqlconnection.Query<users>("SELECT * FROM users WHERE username = @username AND `password` = @password;").ToList();
            return list;
        }
    }
}
